home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / include / RCS / pdev.h,v < prev    next >
Encoding:
Text File  |  1991-11-18  |  12.0 KB  |  424 lines

  1. head     1.8;
  2. branch   ;
  3. access   ;
  4. symbols  sprited:1.8.1;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.8
  10. date     90.02.19.14.44.15;  author douglis;  state Exp;
  11. branches 1.8.1.1;
  12. next     1.7;
  13.  
  14. 1.7
  15. date     89.06.23.11.27.42;  author rab;  state Exp;
  16. branches ;
  17. next     1.6;
  18.  
  19. 1.6
  20. date     89.01.26.09.24.02;  author brent;  state Exp;
  21. branches ;
  22. next     1.5;
  23.  
  24. 1.5
  25. date     89.01.20.15.26.11;  author brent;  state Exp;
  26. branches ;
  27. next     1.4;
  28.  
  29. 1.4
  30. date     88.10.30.14.01.03;  author brent;  state Exp;
  31. branches ;
  32. next     1.3;
  33.  
  34. 1.3
  35. date     88.10.28.11.25.48;  author brent;  state Exp;
  36. branches ;
  37. next     1.2;
  38.  
  39. 1.2
  40. date     88.10.19.14.25.55;  author brent;  state Exp;
  41. branches ;
  42. next     1.1;
  43.  
  44. 1.1
  45. date     88.08.16.12.24.00;  author brent;  state Exp;
  46. branches ;
  47. next     ;
  48.  
  49. 1.8.1.1
  50. date     91.11.17.18.28.34;  author kupfer;  state Exp;
  51. branches ;
  52. next     ;
  53.  
  54.  
  55. desc
  56. @Definitions for pdev library routines.
  57. @
  58.  
  59.  
  60. 1.8
  61. log
  62. @added Pdev_GetStreamID declaration.
  63. @
  64. text
  65. @/*
  66.  * pdev.h --
  67.  *
  68.  * Definitions for pseudo-device library routines.  The man page
  69.  * for pdev (or Pdev_Open) has necessary documentation.
  70.  *
  71.  * Copyright 1988 Regents of the University of California
  72.  * Permission to use, copy, modify, and distribute this
  73.  * software and its documentation for any purpose and without
  74.  * fee is hereby granted, provided that the above copyright
  75.  * notice appear in all copies.  The University of California
  76.  * makes no representations about the suitability of this
  77.  * software for any purpose.  It is provided "as is" without
  78.  * express or implied warranty.
  79.  *
  80.  * $Header: /sprite/src/lib/include/RCS/pdev.h,v 1.7 89/06/23 11:27:42 rab Exp Locker: douglis $ SPRITE (Berkeley)
  81.  */
  82.  
  83. #ifndef _PDEVLIB
  84. #define _PDEVLIB
  85.  
  86. #include <fs.h>
  87. #include <dev/pdev.h>
  88.  
  89. /*
  90.  * Boolean that can be toggled by applications command line arguments.
  91.  * This causes print statements that trace pdev/pfs operations.
  92.  */
  93. extern int pdev_Trace;
  94.  
  95. /*
  96.  * The library keeps a set of callback procedures, one for each pdev request
  97.  * that arrives on a request stream.  Fields can be set to NULL to get
  98.  * a default handler for the operation.  See the man page for the
  99.  * calling sequence of each call-back procedure.
  100.  */
  101.  
  102. typedef struct {
  103.     int (*open)();        /* PDEV_OPEN */
  104.     int (*read)();        /* PDEV_READ */
  105.     int (*write)();        /* PDEV_WRITE and PDEV_WRITE_ASYNC */
  106.     int (*ioctl)();        /* PDEV_IOCTL */
  107.     int (*close)();        /* PDEV_CLOSE */
  108.     /*
  109.      * The following are only used for pseudo-device connnections
  110.      * into a pseudo-file-system.  For regular pseudo-devices the
  111.      * kernel completely handles attributes.
  112.      */
  113.     int (*getAttr)();        /* PDEV_GET_ATTR */
  114.     int (*setAttr)();        /* PDEV_SET_ATTR */
  115. } Pdev_CallBacks;
  116.  
  117. /*
  118.  * A Pdev_Stream is is passed to the PDEV_OPEN call-back handler.
  119.  * This provides a handle on the particular stream to the pseudo-device.
  120.  * The handle for the stream is passed to each call-back procedure.
  121.  */
  122. typedef struct Pdev_Stream {
  123.     unsigned int magic;        /* Either PDEV_MAGIC or PDEV_STREAM_MAGIC */
  124.     int streamID;        /* Sprite stream identifier, either of
  125.                  * control or server stream depending
  126.                  * on context of the token. */
  127.     ClientData clientData;    /* For use by the client of the Pdev package */
  128. } Pdev_Stream;
  129.  
  130. typedef char *Pdev_Token;    /* Opaque token for the pseudo-device */
  131.  
  132. #define PDEV_MAGIC        0xabcd1234
  133. #define PDEV_STREAM_MAGIC    0xa1b2c3d4
  134.  
  135. #ifndef max
  136. #define max(a, b) \
  137.     ( ((a) > (b)) ? (a) : (b) )
  138. #endif
  139.  
  140. extern char pdev_ErrorMsg[];
  141.  
  142. extern    Pdev_Token        Pdev_Open();
  143. extern    void            Pdev_Close();
  144. extern    int               (*Pdev_SetHandler())();
  145. extern    int            Pdev_EnumStreams();
  146. extern    int            Pdev_GetStreamID();
  147.  
  148. extern    Pdev_Stream           *PdevSetup();
  149.  
  150. #endif /* _PDEVLIB */
  151. @
  152.  
  153.  
  154. 1.8.1.1
  155. log
  156. @Initial branch for Sprite server.
  157. @
  158. text
  159. @d16 1
  160. a16 1
  161.  * $Header: /sprite/src/lib/include/RCS/pdev.h,v 1.8 90/02/19 14:44:15 douglis Exp $ SPRITE (Berkeley)
  162. @
  163.  
  164.  
  165. 1.7
  166. log
  167. @*** empty log message ***
  168. @
  169. text
  170. @d16 1
  171. a16 1
  172.  * $Header: /sprite/src/lib/include/RCS/pdev.h,v 1.6 89/01/26 09:24:02 brent Exp Locker: rab $ SPRITE (Berkeley)
  173. d82 1
  174. @
  175.  
  176.  
  177. 1.6
  178. log
  179. @Final adjustments on library interface
  180. @
  181. text
  182. @d16 1
  183. a16 1
  184.  * $Header: /sprite/src/lib/include/RCS/pdev.h,v 1.4 88/10/30 14:01:03 brent Exp Locker: brent $ SPRITE (Berkeley)
  185. d85 1
  186. a85 1
  187. #endif _PDEVLIB
  188. @
  189.  
  190.  
  191. 1.5
  192. log
  193. @Split out the pseudo-file-system stuff into its own file
  194. @
  195. text
  196. @d7 1
  197. a7 1
  198.  * Copyright 1985, 1988 Regents of the University of California
  199. d54 1
  200. a54 4
  201.  * A Pdev_Token is used in two ways.  A (pointer to a) Pdev_Token is returned
  202.  * from the Pdev_Open call.  This provides a top-level handle for the whole
  203.  * pseudo-device.  Then each time a process opens the pseudo-device another
  204.  * (pointer to a) Pdev_Token is passed to the PDEV_OPEN call-back handler.
  205. d58 1
  206. a58 1
  207. typedef struct Pdev_Token {
  208. d64 1
  209. a64 1
  210. } Pdev_Token;
  211. d66 2
  212. d71 5
  213. d78 7
  214. a84 4
  215. extern    ClientData    Pdev_Open();
  216. extern    ReturnStatus    Pdev_Ready();
  217. extern    void        Pdev_Close();
  218. extern    void        Pdev_SetHandler();
  219. @
  220.  
  221.  
  222. 1.4
  223. log
  224. @changed pfsTraceNaming to pdevTrace
  225. @
  226. text
  227. @d4 2
  228. a5 7
  229.  * Definitions for pseudo-device library routines.  See the C file
  230.  *    /sprite/src/lib/c/etc/pdev.c for the implementation of
  231.  *    Pdev_Open and Pdev_Close.  They take care of all the details
  232.  *    of the server-kernel pseudo-device protocol.  Their user only
  233.  *    needs to supply service procedures that are called when client
  234.  *    processes operate on the pseudo-device.  Fs_Dispatch must be
  235.  *    used in order for the service procedures to be called back.
  236. d16 1
  237. a16 1
  238.  * $Header: /sprite/src/lib/include.new/RCS/pdev.h,v 1.3 88/10/28 11:25:48 brent Exp Locker: brent $ SPRITE (Berkeley)
  239. d29 1
  240. a29 1
  241. extern int pdevTrace;
  242. d33 3
  243. a35 5
  244.  * that arrives on a request stream.  They are type IntProc, and are kept
  245.  * as an array (IntProc *).  Pdev_Open and Pfs_Open take an optional argument
  246.  * which defines an array of call back procedures.  The argument can be null,
  247.  * or individual elements of the array can be null, in order to get default
  248.  * handlers for all, or some, of the pdev requests.
  249. a36 1
  250. typedef int (*IntProc)();
  251. d38 15
  252. d54 6
  253. a59 122
  254.  * The calling sequences for the callbacks are as follows:
  255.  * PDEV_OPEN
  256.  *    PdevOpen(token, flags, pid, hostID, uid, privatePtr, selectBitsPtr)
  257.  *        ClientData token;    (Needed for Pdev_Ready call)
  258.  *        int flags;        (flags to open system call)
  259.  *        int pid;        (process ID of opening "client" process)
  260.  *        int hostID;        (Sprite hostID of the client)
  261.  *        int uid;        (User ID of client process)
  262.  *        ClientData *privatePtr;    (Return - reference to private data)
  263.  *                    (that gets passed to other callbacks)
  264.  *        int *selectBitsPtr;    (Return - initial select state of pdev)
  265.  *                (FS_READABLE | FS_WRITABLE | FS_EXCEPTION)
  266.  *
  267.  * PDEV_CLOSE
  268.  *    PdevClose(private)
  269.  *        ClientData private;    (Set by open service procedure)
  270.  *
  271.  * PDEV_READ
  272.  *    PdevRead(private, offset, familyID, numBytesPtr, bufferPtr, freeItPtr,
  273.  *            selectBitsPtr)
  274.  *        ClientData private;    (Set by open service procedure)
  275.  *        int offset;        (Bytes offset at which to read)
  276.  *        int familyID;        (Family ID of calling process)
  277.  *        int *numBytesPtr;    (In/Out - how much to read/was read)
  278.  *        Address *bufferPtr;    (Ref. to buffer to fill in with data)
  279.  *                    ( this can be changed by ReadProc)
  280.  *        int *freeItPtr;        (In/Out boolean indicating if *bufferPtr
  281.  *                    ( needs to be free'd.  If TRUE on entry
  282.  *                    ( ReadProc should free *bufferPtr before
  283.  *                    ( changing the buffer pointer)
  284.  *        int *selectBitsPtr;    (Return - select state of pdev)
  285.  *
  286.  * PDEV_WRITE
  287.  *    PdevWrite(private, offset, familyID, numBytesPtr, buffer, selectBitsPtr)
  288.  *        ClientData private;    (Set by open service procedure)
  289.  *        int offset;        (Bytes offset at which to read)
  290.  *        int familyID;        (Family ID of calling process)
  291.  *        int *numBytesPtr;    (In/Out - how much to write/was written)
  292.  *        Address buffer;        (Buffer containing data)
  293.  *        int *selectBitsPtr;    (Return - select state of pdev)
  294.  *
  295.  * PDEV_IOCTL
  296.  *    PdevIoctl(private, command, familyID, inSize, inBuffer, outSizePtr,
  297.  *            outBuffer, selectBitsPtr)
  298.  *        ClientData private;    (Set by open service procedure)
  299.  *        int command;        (IOControl command)
  300.  *        int familyID;        (Family ID of calling process)
  301.  *        int inSize;        (Size of inBuffer)
  302.  *        Address inBuffer;    (Buffer containing input data)
  303.  *        int *outSizePtr;    (Result - size of outBuffer)
  304.  *        Address outBuffer;    (Buffer containing result data)
  305.  *        int *selectBitsPtr;    (Return - select state of pdev)
  306.  *
  307.  * PDEV_GET_ATTR
  308.  *    PdevGetAttr(private, attrPtr, selectBitsPtr)
  309.  *        ClientData private;    (Set by open service procedure (?))
  310.  *        Fs_Attributes *attrPtr;    (Returned attributes)
  311.  *        int *selectBitsPtr;    (Return - select state of pdev)
  312.  *
  313.  * PDEV_SET_ATTR
  314.  *    PdevSetAttr(private, flags, uid, gid, attrPtr, selectBitsPtr)
  315.  *        ClientData private;    (Set by open service procedure (?))
  316.  *        int flags;        (FS_SET_*, what attrs to set)
  317.  *        int uid;        (User ID of calling process)
  318.  *        int gid;        (Group ID of calling process)
  319.  *        Fs_Attributes *attrPtr;    (Returned attributes)
  320.  *        int *selectBitsPtr;    (Return - select state of pdev)
  321.  *
  322.  * Pseudo-filesystem requests that appear on the naming request-response stream.
  323.  *    For all requests except PFS_OPEN the library handles returning a reply.
  324.  *
  325.  * PFS_OPEN
  326.  *    PfsOpen(private, name, openArgsPtr, pfsToken, redirectInfoPtr)
  327.  *        ClientData private;    (Set by the call to Pfs_Open)
  328.  *        char *name;        (Name of file in pseudo-filesystem)
  329.  *        FsOpenArgs *openArgsPtr;(Specifies mode, uid, gid, and prefixID)
  330.  *        ClientData pfsToken;    (Token needed to open pseudo-device
  331.  *                     connection for the file. From Pfs_Open)
  332.  *        FsRedirectInfo *redirectInfoPtr; (Specifies new pathname)
  333.  *
  334.  *    If this procedure returns SUCCESS then the library assumes that
  335.  *    an IOC_PFS_OPEN or IOC_PFS_PASS_STREAM has been done to reply to
  336.  *    the request.  If an error code is returned then the library does
  337.  *    an IOC_PDEV_REPLY to reply to the request.
  338.  *
  339.  * PFS_GET_ATTR
  340.  *    PfsGetAttr(private, name, openArgsPtr, attrPtr, redirectInfoPtr)
  341.  *        ClientData private;    (Set by the call to Pfs_Open)
  342.  *        char *name;        (Name of file to get attributes of)
  343.  *        FsOpenArgs *openArgsPtr;(Specifies uid, gid, and prefixID)
  344.  *        Fs_Attributes *attrPtr;    (Result - attributes of the file)
  345.  *        FsRedirectInfo *redirectInfoPtr; (Specifies new pathname)
  346.  *
  347.  * PFS_SET_ATTR
  348.  *    PfsSetAttr(private, name, openArgsPtr, flags, attrPtr, redirectInfoPtr)
  349.  *        ClientData private;    (Set by the call to Pfs_Open)
  350.  *        char *name;        (Name of file to get attributes of)
  351.  *        FsOpenArgs *openArgsPtr;(Specifies uid, gid, and prefixID)
  352.  *        int flags;        (FS_SET_*, indicate what attrs to set)
  353.  *        Fs_Attributes *attrPtr;    (New attributes for the file)
  354.  *        FsRedirectInfo *redirectInfoPtr; (Specifies new pathname)
  355.  *
  356.  * PFS_MAKE_DIR
  357.  *    PfsMakeDir(private, name, openArgsPtr, redirectInfoPtr)
  358.  *        ClientData private;    (Set by the call to Pfs_Open)
  359.  *        char *name;        (Name of directory to create)
  360.  *        FsOpenArgs *openArgsPtr;(Specifies mode, uid, gid, and prefixID)
  361.  *        FsRedirectInfo *redirectInfoPtr; (Specifies new pathname)
  362.  *
  363.  * PFS_REMOVE
  364.  *    PfsRemove(private, name, lookupArgsPtr, redirectInfoPtr)
  365.  *        ClientData private;    (Set by the call to Pfs_Open)
  366.  *        char *name;        (Name of file to remove)
  367.  *        FsLookupArgs *lookupArgsPtr;(Specifies uid, gid, and prefixID)
  368.  *        FsRedirectInfo *redirectInfoPtr; (Specifies new pathname)
  369.  *
  370.  * PFS_REMOVE_DIR
  371.  *    PfsRemoveDir(private, name, lookupArgsPtr, redirectInfoPtr)
  372.  *        ClientData private;    (Set by the call to Pfs_Open)
  373.  *        char *name;        (Name of directory to remove)
  374.  *        FsLookupArgs *lookupArgsPtr;(Specifies uid, gid, and prefixID)
  375.  *        FsRedirectInfo *redirectInfoPtr; (Specifies new pathname)
  376. d61 7
  377. d69 3
  378. a77 2
  379. extern    ClientData    Pfs_Open();
  380. extern    ReturnStatus    Pfs_OpenConnection();
  381. @
  382.  
  383.  
  384. 1.3
  385. log
  386. @Added comments for the callback routines
  387. @
  388. text
  389. @d21 1
  390. a21 1
  391.  * $Header: /sprite/src/lib/include.new/RCS/pdev.h,v 1.2 88/10/19 14:25:55 brent Exp Locker: brent $ SPRITE (Berkeley)
  392. d32 1
  393. d34 1
  394. a34 1
  395. extern int pfsTraceNaming;
  396. @
  397.  
  398.  
  399. 1.2
  400. log
  401. @Added externs and IntProc typedef
  402. @
  403. text
  404. @d21 1
  405. a21 1
  406.  * $Header: /sprite/src/lib/include.new/RCS/pdev.h,v 1.1 88/08/16 12:24:00 brent Exp Locker: brent $ SPRITE (Berkeley)
  407. d35 8
  408. d45 125
  409. d177 1
  410. @
  411.  
  412.  
  413. 1.1
  414. log
  415. @Initial revision
  416. @
  417. text
  418. @d21 1
  419. a21 1
  420.  * $Header: sprite.h,v 1.3 88/07/15 16:42:41 ouster Exp $ SPRITE (Berkeley)
  421. d30 7
  422. d42 2
  423. @
  424.